package basedeal

import (
	"context"
	"core/server/baseserver"
	"errors"
	"iotall/iotcore/api/proxyup"
	"iotall/iotcore/entity"
)

type HttpDeal struct {
	CommPort *entity.CommPort
	//CClients sync.Map

	baseserver.BaseServer

	ChildDeal func(ctx context.Context, in *proxyup.UpReq) (*proxyup.UpResp, error)
}

func (p *HttpDeal) Start() {
	//p.connList = &corestruct.Queue{}
	//p.upList = &corestruct.Queue{}

	p.BaseServer.DoInterval = p.DoInterval
	p.BaseServer.DoClose = p.DoInterval

	p.BaseServer.Start()
}
func (p *HttpDeal) Close() {
	p.BaseServer.Close()

}
func (p *HttpDeal) DoInterval() {

}

func (p *HttpDeal) GetClientNum() int32 {
	//var len int32 = 0
	//p.CClients.Range(func(k, v interface{}) bool {
	//	len++
	//	return true
	//})
	//return len
	return 0
}

func (p *HttpDeal) GetCommPortId() int64 {
	return p.CommPort.Id
}

func (p *HttpDeal) UpFunc(ctx context.Context, in *proxyup.UpReq) (*proxyup.UpResp, error) {
	var r, err = p.ChildDeal(ctx, in)
	return r, err
}
func (p *HttpDeal) CloseFunc(ctx context.Context, in *proxyup.CloseReq) (*proxyup.CloseResp, error) {
	return nil, errors.New("不支持的方法")
}
